package JdbcUtilDemo;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class JndiDemo {
	Connection conn=null;
	public Connection getConnection(){
		try {
			Context cxt=new InitialContext();
			DataSource ds=(DataSource)cxt.lookup("java:comp/env/jdbc/BIN");
			Connection conn=ds.getConnection();
			System.out.println(conn);
		} catch (NamingException e) {
			 
			e.printStackTrace();
		} catch (SQLException e) {
			 
			e.printStackTrace();
		}
		
		return conn;
	}
	
}
